package com.example.javabasic.thread.classtwo.activeobject.demo1;

/**
 * 实际执行逻辑.   业务由这里处理
 */
class Servant implements ActiveObjects {
    @Override
    public Result makeString(int count, char fillChar) {
        char[] buf = new char[count];
        for (int i = 0; i < buf.length; i++) {
            buf[i] = fillChar;
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return new RealResult(new String(buf));
    }

    @Override
    public void displayString(String text) {
        try{
            System.out.println("display:"+text);
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
